package org.duiduo.controller;

import org.duiduo.api.request.UserRegisterRequest;
import org.duiduo.api.response.Result;
import org.duiduo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 登录相关控制层
 *
 * @author liangze
 * @date 2021/9/24 11:43
 */
@RestController
public class LoginController {

    @Autowired
    private UserService userService;

    /**
     * 注册功能
     *
     * @param request
     * @return
     */
    @PostMapping("/register")
    public Result<?> register(@RequestBody @Valid UserRegisterRequest request) {
        return Result.success(userService.register(request));
    }

}
